<h1>Editing purchase</h1>

<% form_for(@purchase) do |f| %>
  <%= f.error_messages %>
  <table>
  	<tr>
  		<td><%= f.label :receipt %></td>
  		<td><%= select("purchase","receipt_id",Receipt.find(:all, :order => "rDate DESC").collect {|r| [r.store.company.name + ' - ' + r.rDate.to_s,r.id]}) %></td>
  	</tr>
	<tr>
		<td><%= f.label :item %></td>
		<td>
			<%= select("purchase","item_id",Item.find(:all).collect {|i| [i.brand != nil ? i.brand.name + ' ' + i.name : i.name,i.id]}) %>
			<%= observe_field :purchase_item_id, :update => :measure, :url => { :action => :item_measure }, :with => 'purchase_item_id' %>
		</td>
	</tr>
	<tr>
		<td><%= f.label :quantity %><br /></td>
		<td><%= f.text_field :quantity, :size => 2 %> <span id="measure"><%=h f.item.measure.unit rescue nil %></span></td>
	</tr>
	<tr>
		<td><%= f.label :price %></td>
		<td><%= f.text_field :price, :size => 2 %></td>
	</tr>
	<tr>
		<td><%= f.label :tax_rate %></td>
		<td><%= f.text_field :tax_rate, :size => 2 %></td>
	</tr>
	<tr>
		<td><%= f.label :sale %></td>
		<td><%= f.check_box :sale %></td>
	</tr>
	<tr>
		<td><%= f.label :coupon %></td>
		<td><%= f.text_field :coupon, :size => 2 %></td>
	</tr>
	<tr>
		<td><%= f.label :notes %></td>
		<td><%= f.text_area :notes, :size => "40x3" %></td>
	</tr>
  </table>
  <p>
    <%= link_to 'Cancel', @purchase.receipt %> | <%= f.submit "Update" %>
  </p>
<% end %>
